<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
use app\model\not_del\UserModel as NotDelUserModel;

/**
 * 关注用户（关注人群）
 */
class FollowUserModel extends BaseModel
{
    protected $name = 'follow_user';

    /**
     * 关联用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_name'=>'name',
            'user_avatar'=>'avatar',
            'user_sex' => 'sex',
            'user_age' => 'age',
            'user_number',
            'username',
            'student_status',
            'unit_name',
            'department_id',
            'department_name',
            'departmentAdmins'
        ]);
    }

    public function userName(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_name'=>'name',
        ]);
    }

    /**
     * 关注人群跟进记录
     * @return HasMany
     */
    public function FollowUp(): HasMany
    {
        return $this->hasMany('FollowUpModel','follow_id');
    }

    /**
     * 负责人（操作人）
     * @return BelongsTo
     */
    public function operator(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'operator_uid')->bind([
            'operator_name'=>'name',
            'operator_role_name' => 'role_name'
        ]);
    }
}